class Solution {
public:
    int firstMissingPositive(vector<int>& nums)
    {
        unordered_map<int, int> hash;
        for (auto num : nums)
        {
            if (num > 0)
                hash[num] = 1;
        }
        int i = 0;
        for (i = 1;; i++)
        {
            if (!hash.count(i))
            {
                return i;
            }
        }
        return -1;
    }
};